package view;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;

import controlador.Tragamonedas;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;



public class PanelTransferirFondos extends JPanel implements ActionListener{

	private static final long serialVersionUID = 1L;
	private JTextField textField_monto;
	private JLabel lblTransferirFondos;
	private JLabel lblMonto;
	private JButton btnTransferir;
	private Tragamonedas sys;


	public PanelTransferirFondos(Tragamonedas sys) {
		setLayout(null);
		this.sys = sys;
		
		lblTransferirFondos = new JLabel("Transferir Fondos");
		lblTransferirFondos.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblTransferirFondos.setBounds(72, 11, 130, 14);
		add(lblTransferirFondos);
		
		
		lblMonto = new JLabel("Monto:");
		lblMonto.setBounds(28, 82, 121, 14);
		add(lblMonto);
		
		textField_monto = new JTextField();
		textField_monto.setBounds(145, 79, 110, 20);
		add(textField_monto);
		textField_monto.setColumns(10);
		

		
		btnTransferir = new JButton("Transferir");
		btnTransferir.addActionListener(this);
		btnTransferir.setBounds(87, 118, 91, 23);
		add(btnTransferir);

	}


	@Override
	public void actionPerformed(ActionEvent event) {
		if(event.getSource() == btnTransferir){
			this.sys.actualizarRecaudacion(Float.parseFloat(this.textField_monto.getText()));
			
			JOptionPane.showMessageDialog(null,
					"Se han transferido " + this.textField_monto.getText(), "Informacion",
					JOptionPane.INFORMATION_MESSAGE);
		}
		
	}

}
